package cn.dengl.sky.springboot.sys.controller;

import cn.dengl.sky.springboot.common.base.controller.GenericController;
import cn.dengl.sky.springboot.common.base.service.GenericService;
import cn.dengl.sky.springboot.sys.entity.QueryUser;
import cn.dengl.sky.springboot.sys.entity.User;
import cn.dengl.sky.springboot.sys.service.UserService;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/user")
public class UserControler extends GenericController<User,QueryUser> {
    @Resource
    private UserService userService;
    @Override
    protected GenericService<User, QueryUser> getService() {
        return userService;
    }

    @RequestMapping(value = "/save",method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public Map<String,Object>addUser(User user){
        return userService.addUser(user);
    }
    @RequestMapping(value="/query",method = RequestMethod.GET)
    @ResponseBody
    public List<User> getUserList(String flag){
        return userService.loadAll();
    }
}
